package com.icbc.api;

import com.icbc.api.internal.util.codec.Base64;
import com.icbc.api.internal.util.internal.util.fastjson.JSONObject;
import com.icbc.api.request.*;
import com.icbc.api.response.*;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class JftApiUserOpenacctH5QueryTestV1 {

    // FIXME：此处替换工行API网关公钥，请向工行联系获取
//    private static final String APIGW_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB";
//    private static final String APP_ID = "11000000000000009957";
//    private static final String MY_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9nMkFzD605xr4kmV9r7neFN3CfTTLKBKLllwvI4+2b5JiJxogto7V/nA+ka8b8Qqhs6c8LdrEsHJe8FtRrT4XTw83m6w8/kLoFhs8VWbUa0/d+iIUpt8ziwX/fgIEJ+lbYo7oQSqAVBEVjzAsX4VmY+umiretKehOG1ePMSmGUiQcjbHc7jDSHIzYhITw7fRovyvdsUryTcr+fA2OlWR1AsIh42ic/OdMuUW05gAh3HrB3NmUIZv37o2v4ZYUxGL8brYG0H8rD0UEETZO5OcYtXiszwFDjkEcp4V0aIVISRWCbPPujL3b+Oy30CXJYN0KaRcZu70MHyuZ6ZN4Yy/xAgMBAAECggEATREFj4q1TffEuZVfFNewlvgqLhuPsqbl6sBBVZOBnOf6OlSkRPmOUqHo4zV5U8UDyjdn2IjWqy0AP2A37ZmZbAXhLHvkZKH/da9OgJZBhkLbomBBK92rSJrP5ElF7oR+T3telD2wVZpVm0qojNCCOtyP8g/dmc83sU9hpjyYIRRcoZE19e+mo9MsjSToEpTNML1kUZ3nGdA/9Kbv5mNqoKZTHAylajgjJIG6h4+/HhszTzXImJjfVPVfH6E7tfLzD3XsIDFpZdecaKwzsdMHmClxIjHW0+KCGwsrHCXXwW1gjEw6RT2ar/WmK6h7KqkFB7VPeMQ1QoK9x3QuYUAaVQKBgQDgonE8cv5amZ6h/rgpYSX71Blx82XMIOVf0Nk6k8lPFJ6izvg4mztlzIFQRpUq0Ju/hZTKiT2SH0Isf5hjWFXPov6A2ASuc8blTI2t1KCKVPC2byEgGeGYS0HodV8hhjMrONqGwy4lQUlAJ8wLJGn4xW9jflUU2J5VsWN5jh39dwKBgQDYFnqIWuZdXwrJi/KAGz47lz8Lh3TX4gzcHUyDy0dl7FBJx8SROtt4cP8Z/Llt9LBxK+ngNzEKPfaaK58OjNBw8GwlelJITKH9viOptgxWbe9mB6N4kAtYFTUT6nhibeUJEtTl7Fp5S/slRRgsQmoi7wr9T4mLKQ5yQ0Szuud31wKBgQCNQ9quRyrJ0x29hjBOZXe7nLC7xnNYIb/dt7tEaTgJ8U+p1zqmboi2Bhu0Xg7ks/eeQ+VEUXZU9C9rSHqOzzh3sWsXn8Gh69FC1herH7IuDCisscpFI8GJQpqaE2XV8U0wezqB0TCt4Ratr9lTkHzMI21fRk0/JNK91SZXhRY7FQKBgHxGOURQWupaLb8KEHZitKDa9DQyPB2ocNLqusWVVEOm6+nyzPblTbFv8xbEBPTa49rCcag0tax5RGkYK0rX60z4yImpVscj44omHyaMf335jdQ1EmvVE+EdmUAR+hhJsY5NWUm+a64U56Rgn21c6OOcbMqQQr9Y5mkKjOl81YBTAoGAOFvkQFH1kWdnKD2hMhLgBObNPZq1u9uDh7CgWzDGaHxqgyE+x6s+WZ+gYv3xPUGybVBAtqS0Gi68NOSDblaZi311kEtcNgHR1F5hYf6UfRfpXL0icu2qwydF7ZQtbud4EAlu/gO95CSW/x6sy6xxqrVfRhAHezX/epc6ZOgt2y4=";
//    private static final String AES_Key = "5xGJdh7qb+B95SUoxDlatg==";


    private static final String APIGW_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB";
    private static final String APP_ID = "11000000000000012156";
    private static final String MY_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCpsM9nQ4CHOTxdpcx3sW+rzbEJaGvICBF7hx9QKPXMcT5AF41Te8G4/7LknnymMHG/wyNDu4giitifAMtR865Hm/SM/7zqEnbCC2ACtfqsMm/N3cPkhZc3rMsY87WMWCPj0cD5+7URa1C38ByqkWyCi+6IelCVxk36FNOnS7d5sD3hSCFoypZB6SIkGfXx/ZXrc7WlA0vB6uZx5OXzN2ga0OE85IJqez2rNjNwy3c0xWDrmeDfEiIQgeClRNenmhmVyiPF/3qJTfkPBFAuROS4ojtddnZh+vR1MBC28aZArsyvOtslybVonnlPZ2FOTNd3cymI9YQqo+0E2fzRB1ihAgMBAAECggEAZvtL05KOxQICVZ8SaK2BZRWO1HPPvXTQD1Sgt0g0a99p9QGWHk0j8z8S9VYNtdn+nm8xzqBX7QawkkasHc8yPHk0QAHQR4nvErJOkTaZq7lsStbEVMKSVBKEq170FflDxrX8VHnimHC1avvImedpoAyGNcNtdogDuLq8/HGiJrHDE2gQ0IVR6jxF3523Jw2e0LINgvFks8/c/VBUshAtmViYU2AMqkE068ymkmzCPRyi1R1BUw8MkpCZBtbjroaioj+Tl5TXmtcXFqpt+VpQZwrs2Ycx9IOo54MXytq53cq/Z6dvA0JAJbruyjBR614ZP6Qunz3e1N7TWaSu5ocTxQKBgQD3e10rwuiBHVz06hlukWswbXEbBt0u45qinyY3qHtrNi8n5OEW708qsZPI+zy3xqLiK+we2J9oQe6a97Plx2GBRt86IFvSXWt5HP5FeaT+LjnPZ0TzVKYBFfx3zvfkobO+2bvdT94slhuskFOQO2lMje/o6gUl7WhZ4aUqcBP98wKBgQCviAE3NOiJHnUYNkcoh7HNFgqzJbwk4WzYKiuN/AXZZGvaNXqeHYcoAnl7zHluoiE74Zror/iTZW76ruYq41CkCvWceNg9/XXGQM9O0yHD97/gIbQ8FA98J0ZLHv3gpElv0jH2GdSFcXksgHf2QNA3WTCriq4VlDLnQOQxwPowGwKBgQCp/nJEchC1R88naHppqbfgPvzXXMKnx63bkMh2qOOGBGUl2SEIWP+fSvVBs9nEPsx54UPC+Hee7NMSXZ2T8321iFIjokCQYp1FRzYd0O4VrvkEz2HcZ0PUMR8HyQIcaTqHmRZjcc4iAEYoJcdQpo6xCDpIWh+JKudn/ggu+2ewIwKBgF+QTBkiVPdR/a4Q3uzR85sURP8DrErn77pAOzYx331bjtxeAUPUD6FYt4sO542z9yQCz7OfGlYlAya30dfHqj+lN9LYd+JH+7bT0gm4KMnoOC5uKxIKWePd/gcn+FA1IUYfydOSfIGqJa50wtrurm1zwWujNOPKq2v7iEEOLyfBAoGBAMJsn/HJsFHfTCg3WpB+5Q+y1Qlbic3yU5n6sb5XEiWo8PUpJ/l1e0RFYyN9du1NincYIzX2amVB1dQoQfYcuTjeZq0GQGGYFbv8p25iFPx/0nTvTkKp943St5qKz/PFMo8qGnnxJMM8w4QdOxZc05th1UBqPuvYSLcqhK8RhB0O";
    private static final String AES_Key = "5xGJdh7qb+B95SUoxDlatg==";


    private static final String HTTP_URL = "https://apipcs3.dccnet.com.cn";

    //《聚富通智慧清分收方修改接口V1》
    private static final String update_URL = HTTP_URL + "/api/jft/api/user/edpreceive/update/V1";
    //《聚富通智慧清分收方删除接口V1》
    private static final String delete_URL = HTTP_URL + "/api/jft/api/user/edpreceive/delete/V1";
    //《聚富通网络货运收方审核异步通知》
    //《聚富通网络货运收方入驻页面服务V1》
    String aa = "/ui/jft/ui/user/edpopenacct/submit/V1";
    //《聚富通网络货运收方入驻结果展示页面服务V1》
    String edpopenacct_info = HTTP_URL + "/ui/jft/ui/user/edpopenacct/info/V1";
    //《聚富通网络货运收方入驻结果查询数据服务V1》
    String cc = "/api/jft/api/user/edpopenacct/query/V1";
    //《划款结果通知接口》
    //《聚富通网络货运智慧清分接口》
    //《聚富通交易流水查询接口》
    String dd = "/api/jft/api/b2bpay/transquery/V1";
    //《聚富通管家卡入账结果通知接口》
    //《聚富通运单信息登记》
    String ff = "/api/jft/api/b2bpay/NetworkTransPortDepositRegist/V1";
    //《聚富通用户基本信息查询接口》
    //《聚富通用户基本信息修改接口》
    String ee = "/api/jft/api/vendor/enterprise/info/modify/V1";
    //《聚富通用户基本信息注册接口》
    //《聚富通图片上传接口V1》
    String gg = "/api/jft/api/vendor/pic/upload/V1";
    //《聚富通图片下载接口V1》
    String hh = "/api/jft/api/vendor/pic/download/V1";
    //《聚富通网络货运对账单文件获取接口》

    //《聚富通基本信息注册及融资档案信息维护接口V1》
    // /api/jft/api/vendor/finance/switch/V1
    //《聚富通经营快贷查询接口V1》
    // /api/jft/api/vendor/query/finance/info/V1
    //《聚富通用户基本信息修改接口》
    // /api/jft/api/vendor/enterprise/info/modify/V1
    //《聚富通图片上传接口V1》
    // /api/jft/api/vendor/pic/upload/V1
    //《聚富通图片下载接口V1》
    // /api/jft/api/vendor/pic/download/V1
    //《聚富通B2B预订单接口V1》
    // /api/jft/api/pay/b2bpay/genpreorder/V1
    //《聚富通B2B融资支付移动端页面接口V1》
    // /ui/jft/ui/pay/b2bpay/loanpayh5/V1
    //《聚富通B2B融资支付受理页面接口V1》
    // /ui/jft/ui/pay/b2bpay/loanpayconfirm/V1
    //《贷款人可贷额度查询接口（企业）》
    // /api/jft/api/loan/qryloanlimitbusis/V1
    //《聚富通融资评价预估额度查询V1》
    // /api/jft/api/loan/marklist/qryprelimit/V1
    //《聚富通B2B通用查询数据接口V1》
    //《获取对账单token接口V1》
    //《B2B对账单下载接口说明》
    //《聚富通融资参数上传通知平台方接口》
    //《聚富通B2B通用通知接口》

    /*融资预授信及贷后  这几个是走专用接口*/
    //《贷款申请接口》
    //《企业税务信息授权接口》
    //《贷后管理基础信息接口》


    public static void main(String[] args) {
        // 声明工行开放平台 API 数据接口请求 Client 实体类，传入配置项
        DefaultIcbcClient client = new DefaultIcbcClient(
                APP_ID,
                IcbcConstants.SIGN_TYPE_RSA2,
                MY_PRIVATE_KEY,
                IcbcConstants.CHARSET_UTF8,
                IcbcConstants.FORMAT_JSON,
                APIGW_PUBLIC_KEY,
                IcbcConstants.ENCRYPT_TYPE_AES,
                AES_Key,
                "", "");
//        test1(client);
//       test2(client);
//       test3(client);
//       test4(client);
//       test5(client);
//        test6(client);
//        test7(client);
//        test8(client);
//        getToken(client);
//        test10(client);

        // TODO test11(client);
//        test12();

//        test13(client);

        test14(client);





        System.out.println("===== test over ======");
    }

    // 聚富通B2B预订单接口V1
    public static void test14(DefaultIcbcClient client){

        JftApiPayB2bpayGenpreorderRequestV1 request = new JftApiPayB2bpayGenpreorderRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/pay/b2bpay/genpreorder/V1");
                JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz bizContent =
                        new JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz();
        bizContent.setAppId(APP_ID);
        bizContent.setOutOrderId("20201128531215026");
        bizContent.setPayMethod("01");
        bizContent.setPayMethod("01");
        bizContent.setMultiRecFlag("1");
        bizContent.setStlFlag("0");
        bizContent.setAsynFlag("0");
        bizContent.setOutVendorId("04221125");
        bizContent.setOutUserId("202004221117");
        bizContent.setRecAcctId("123654123");
        bizContent.setPayerAcctId("1001765234");
        bizContent.setTradeTime("2024-04-30 15:36:56");
        bizContent.setTrxChannel("01");
        bizContent.setTrxIp("183.230.2.164");
        bizContent.setPayModeTool("1");
        bizContent.setPayPhoneno("1388888888");
        bizContent.setPayerType("1");
        bizContent.setOrderAmount("2.00");
        bizContent.setPayAmount("2.00");
        bizContent.setFloatRate("888");
        bizContent.setProvince("北京");
        bizContent.setCity("北京");
        bizContent.setCounty("西城");
        bizContent.setEmail("123456@icbc.com");
        bizContent.setPhone("1388888888");
        bizContent.setAddress("北京");
        bizContent.setPost("5168845");
        bizContent.setPayRem("试一下");
        bizContent.setOrderRem("食品");
        bizContent.setAddRemark("食品");
        bizContent.setPayerName("XX集团");
        bizContent.setPayerAcctNum("XX集团");
        bizContent.setCurrency("001");
        bizContent.setPayerWalletId("1234567890123456789012");
        bizContent.setPayerWalletName("XXXXX有限公司");
        bizContent.setNotifyUrl("http://www.xxx.com");
        bizContent.setJumpUrl("http://www.xxx.com");
        JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.Good
                goodsInfo = new
                JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.Good();
        goodsInfo.setGoodsSeqno("1");
        goodsInfo.setGoodsName("牛肉干");
        goodsInfo.setGoodsNum("10");
        goodsInfo.setGoodsAmt("10");
        goodsInfo.setWeight("肉干");
        goodsInfo.setPrice("50");
        goodsInfo.setSellerAddress("13866668");
        goodsInfo.setSellerName("牛大");
        goodsInfo.setUnits("斤");
        goodsInfo.setOutVendorId("04221125");
        JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.Good
                goodsInfo2 = new
                JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.Good();
        goodsInfo2.setGoodsSeqno("2");
        goodsInfo2.setGoodsName("牛肉干");
        goodsInfo2.setGoodsNum("10");
        goodsInfo2.setGoodsAmt("10");
        goodsInfo2.setWeight("肉干");
        goodsInfo2.setPrice("50");
        goodsInfo2.setSellerAddress("13866668");
        goodsInfo2.setSellerName("牛大");
        goodsInfo2.setUnits("斤");
        goodsInfo2.setOutVendorId("04221120");
        List<JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.Good>
                goodList = new ArrayList<>();
        goodList.add(goodsInfo);
        goodList.add(goodsInfo2);
        bizContent.setGoodsInfo(goodList);
        JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.RecInfo
                recInfo1 = new
                JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.RecInfo();
        recInfo1.setOutVendorId("04221125");
        recInfo1.setRecAcctId("123654123");
        recInfo1.setTrxAmount("1.00");
        recInfo1.setOrderAmount("1.00");
        JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.RecInfo
                recInfo2 = new
                JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.RecInfo();
        recInfo2.setOutVendorId("04221120");
        recInfo2.setRecAcctId("04187335");
        recInfo2.setTrxAmount("1.00");
        recInfo2.setOrderAmount("1.00");
        List<JftApiPayB2bpayGenpreorderRequestV1.JftApiPayB2bpayGenpreorderRequestV1Biz.RecInfo>
                recList = new ArrayList<>();
        recList.add(recInfo1);
        recList.add(recInfo2);
        bizContent.setRecList(recList);
        bizContent.setSummary("测试一下");
        bizContent.setPurpose("测试一下");
        request.setBizContent(bizContent);
        JftApiPayB2bpayGenpreorderResponseV1 response = null;
        try {
            response = client.execute(request);
            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
        System.out.println(response);

    }

    // 聚富通b2b通用查询数据接口
    private static void test13(DefaultIcbcClient client) {
        JftApiB2bPayQueryRequestV1 request = new JftApiB2bPayQueryRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/pay/b2bpay/querytraninfo/V1");
        JftApiB2bPayQueryRequestV1.JftApiB2bPayQueryRequestV1Biz bizContent = new JftApiB2bPayQueryRequestV1.JftApiB2bPayQueryRequestV1Biz();
        bizContent.setAppId(APP_ID);//平台商户标识
        bizContent.setOutVendorId("20230919A02");//子商户标识
        bizContent.setOutOrderId("out20220101a");//所查订单的ID
        bizContent.setTradeTime("2023-12-12 14:14:00");//交易时间
        bizContent.setOrderType("02");//订单类型
        bizContent.setBizMode("02");//业务模式
        bizContent.setOriOrderId("12019032166482801129");//原订单号，订单结算必传
        request.setBizContent(bizContent);
        JftApiB2bPayQueryResponseV1 response;
        try {
            response = client.execute(request, System.currentTimeMillis() + "");//msgId消息通讯唯

            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }



    public static void test12() {

//        String appId = "11000000000000009957"; // 平台合作方注册获得的appid值
        String token = "1714460674195e497be24b1b548e4bf2455a045dd3148"; // 获取token接口返回的token值
//        String randomValue = "6xx93"; // 获取token接口返回的随机数
        String acDate = "2024-04-07"; // 上送日期，格式"yyyy-MM-dd"

        Random random = new Random();
        String  randomValue = String.valueOf(random.nextInt(100000));
        try {
            URL url = new URL(HTTP_URL + "/jftvendor/jftFileDownload/b2bFile/download/"
                            + APP_ID + "/"
                            + token + "/"
                            + randomValue + "/"
                            + acDate);
            URLConnection urlConnection = url.openConnection();
            HttpURLConnection httpUrlConnection = (HttpURLConnection) urlConnection;
/**
 * 通过getHeaderFields方法，获取头文件中的参数map，key = "rets",获取到响应信息的
 List<String>
 * List中第一个参数为响应码；第二个参数为响应信息
 * 响应信息为utf-8编码，所以读取时也需要使用utf-8解码
 */
            Map<String, List<String>> map = httpUrlConnection.getHeaderFields();
            List<String> retList = map.get("rets");
            System.out.println("retList  ===  " + retList);
            System.out.println("map  ===  " + map);
            String retcode = "";
            String retmsg = "";
            if (retList != null && retList.size() > 0) {
                retcode = URLDecoder.decode(retList.get(0), "utf-8");
                retmsg = URLDecoder.decode(retList.get(1), "utf-8");
            }
            if ("0000".equals(retcode)) {//响应码"0000"为下载成功
                System.out.println(retmsg);
                InputStream is = httpUrlConnection.getInputStream();
                byte[] buffer = new byte[1024];
                File file = new File("E:\\aaa.zip");
                FileOutputStream fos = new FileOutputStream(file);
                int i = -1;
                while ((i = is.read(buffer)) != -1) {
                    fos.write(buffer, 0, i);
                }
                is.close();
                fos.flush();
                fos.close();
            }
            if ("0401".equals(retcode)) {
//"0401"，未找到对账文件
                System.out.println(retmsg);
            }
            if ("0402".equals(retcode)) {
//"0402"，token验证失败
                System.out.println(retmsg);
            }
            if ("0403".equals(retcode)) {
//"0403"，appId有误，未找到内部编号，请联系工行
                System.out.println(retmsg);
            }
        } catch (IOException e) {
// TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void test11(DefaultIcbcClient client) {
        JftApiLoanMarklistQryprelimitRequestV1 request = new JftApiLoanMarklistQryprelimitRequestV1();
        JftApiLoanMarklistQryprelimitRequestV1.JftApiLoanMarklistQryprelimitRequestV1Biz bizContent = new JftApiLoanMarklistQryprelimitRequestV1.JftApiLoanMarklistQryprelimitRequestV1Biz();
        bizContent.setAppId(APP_ID);
        bizContent.setWhiteType("1");
        bizContent.setWhiteModelType("11");
        bizContent.setOutSerialNo("11");
        bizContent.setUserType("1");
        bizContent.setOutUserId("1");
        request.setServiceUrl(HTTP_URL + "/api/jft/api/loan/marklist/qryprelimit/V1");
        request.setBizContent(bizContent);
        JftApiLoanMarklistQryprelimitResponseV1 response;
        try {
            response = (JftApiLoanMarklistQryprelimitResponseV1) client.execute(request, System.currentTimeMillis() + "");
            System.out.println(JSONObject.toJSONString(response));
            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void test10(DefaultIcbcClient client) {
        JftApiLoanQryLoanLimitBusisRequestV1 request = new JftApiLoanQryLoanLimitBusisRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/loan/qryloanlimitbusis/V1");
        JftApiLoanQryLoanLimitBusisRequestV1.JftApiLoanQryLoanLimitBusisRequestV1Biz bizContent = new JftApiLoanQryLoanLimitBusisRequestV1.JftApiLoanQryLoanLimitBusisRequestV1Biz();
        bizContent.setAppId(APP_ID);
        bizContent.setOutSubVendorId("20230919A03");
        bizContent.setVersion("1.0.0");//设置接口访问版本号
        request.setBizContent(bizContent);
        JftApiLoanQryLoanLimitBusisResponseV1 response;
        try {
            response = (JftApiLoanQryLoanLimitBusisResponseV1) client.execute(request, System.currentTimeMillis() + "");
            System.out.println(JSONObject.toJSONString(response));
            if (response.isSuccess()) {
// 业务成功处理
                System.out.println(response.getReturnCode());
            } else {
// 失败
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }

    public static void getToken(DefaultIcbcClient client) {
        TokenRequestV1 request = new TokenRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/vacct/token/get/V1");
        TokenRequestV1.TokenRequestV1Biz bizContent = new TokenRequestV1.TokenRequestV1Biz();
        bizContent.setAppId("11000000000000009957");//appId外部商户编号
        bizContent.setVersion("1.0.0");//版本号
        bizContent.setValidTime("1800");//有效时间。单位s，默认5分钟（300s）上限30分钟（1800s）
        request.setBizContent(bizContent);
        TokenResponseV1 response;
        try {
            response =
                    (TokenResponseV1) client.execute(request, System.currentTimeMillis() + "");
            System.out.println(JSONObject.toJSONString(response));
            if (response.isSuccess()) {
                System.out.println(response.getReturnCode());
            } else {
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }

    public static void test8(DefaultIcbcClient client) {
        JftApiB2bpayTransqueryRequestV1 request = new JftApiB2bpayTransqueryRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/b2bpay/transquery/V1");
        JftApiB2bpayTransqueryRequestV1.JftApiB2bpayTransqueryRequestV1Biz bizContent = new
                JftApiB2bpayTransqueryRequestV1.JftApiB2bpayTransqueryRequestV1Biz();
        bizContent.setAppId(APP_ID);
        bizContent.setOutVendorId("1712137033952");
        bizContent.setOutUserId("874");
        bizContent.setBatchNo("123465");
        bizContent.setCardNo("94300001000211");
        bizContent.setPayAccount("62510023339444202");
        bizContent.setStartTrxDate("20220308");
        bizContent.setEndTrxDate("20220308");
        bizContent.setStartId("1");
        bizContent.setEndId("50");
        request.setBizContent(bizContent);
        JftApiB2bpayTransqueryResponseV1 response = null;
        try {
            response = (JftApiB2bpayTransqueryResponseV1)
                    client.execute(request);
            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }

        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
        System.out.println(response);
    }

    public static void test7(DefaultIcbcClient client) {
        // 运单信息登记
        JftApiB2bpayDepositregistRequestV1 request = new JftApiB2bpayDepositregistRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/b2bpay/NetworkTransPortDepositRegist/V1");
        JftApiB2bpayDepositregistRequestV1.JftApiB2bpayDepositregistRequestV1Biz bizContent = new
                JftApiB2bpayDepositregistRequestV1.JftApiB2bpayDepositregistRequestV1Biz();
        List<JftApiB2bpayDepositregistRequestV1.JftApiB2bpayDepositregistRequestV1Biz.OriTrx>
                oriTrxes = new ArrayList<>();
        JftApiB2bpayDepositregistRequestV1.JftApiB2bpayDepositregistRequestV1Biz.OriTrx
                oriTrx = new JftApiB2bpayDepositregistRequestV1.JftApiB2bpayDepositregistRequestV1Biz.OriTrx();
        bizContent.setAppId("11000000000000009957");
        oriTrx.setDetailNo("1001");
        oriTrx.setOriAmount("2.01");
        oriTrx.setOriSerialNo("10011");
        oriTrxes.add(oriTrx);
        bizContent.setOriTrxList(oriTrxes);
        bizContent.setProjectId("2023072512");
        bizContent.setAmount("100.00");
        bizContent.setSceneType("02");
        bizContent.setSourceAddress("北京市");
        bizContent.setProjectName("货运项目");
        bizContent.setDestinationAddress("北京市");
        bizContent.setProjectType("123");
        bizContent.setProjectAmount("200.01");
        bizContent.setOtacctFlag("0");
        bizContent.setImageFile("asd‐xsssdff");
        bizContent.setImageFileUrl("http://www.xxxx.com");
        bizContent.setWtBankNo("105145300736");
        bizContent.setWtBankName("中国工商银行");
        bizContent.setRemark("备注");
        bizContent.setBatchId("smq20230825552");
        request.setBizContent(bizContent);
        JftApiB2bpayDepositregistResponseV1 response = null;
        try {
            response = (JftApiB2bpayDepositregistResponseV1) client.execute(request);
            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }

    private static void test6(DefaultIcbcClient client) {

        JftApiVendorEnterpriseInfoModifyRequestV1 request = new
                JftApiVendorEnterpriseInfoModifyRequestV1();
//4、根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl(HTTP_URL + "/api/jft/api/vendor/enterprise/info/modify/V1");
//5、请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        JftApiVendorEnterpriseInfoModifyRequestV1.JftApiVendorEnterpriseInfoModifyRequesBiz bizContent = new
                JftApiVendorEnterpriseInfoModifyRequestV1.JftApiVendorEnterpriseInfoModifyRequesBiz();
//必填
        bizContent.setAppId("11000000000000012156");
        bizContent.setOutVendorId("1712137033952");
        bizContent.setBizType("01");
//非必填
//        bizContent.setOutVendorManagerId("1111111111111111");
        bizContent.setVendorName("果果测试2");
        bizContent.setOutUserId("874");
//        bizContent.setVendorShortName("集团会员01修改测试");
//        bizContent.setVendorPhone("18888888888");
//        bizContent.setVendorEmail("aa@qq.com");
//        bizContent.setProvince("130000");
//        bizContent.setCity("130100");
//        bizContent.setCounty("130102");
//        bizContent.setAddress("xx街xx");
//        bizContent.setPostcode("100001");
//        bizContent.setOperatorName("专用");
//        bizContent.setOperatorMobile("18612345678");
//        bizContent.setOperatorEmail("zhangsan@163.com");
//        bizContent.setOperatorIdNo("110101198506230318 ");
//        bizContent.setVendorType("01");
//        bizContent.setCorporateName("小东东");
//        bizContent.setCorporateMobile("18901230125");
//        bizContent.setCorporateIdType("0");
//        bizContent.setCorporateIdNo("110101198506230318");
//        bizContent.setCorporateIdPic1("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setCorporateIdPic2("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setCertType("101");
//        bizContent.setCertNo("1000000000000123123");
//        bizContent.setCertPic("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setOtherCertPic1("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setOtherCertPic2("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setOtherCertPic3("mere73ffaf4499740678fcc6e9dd542698e");
//        bizContent.setAccountBizType("2");
//        bizContent.setAccountName("小东东");
//        bizContent.setAccountBankProvince("上海");
//        bizContent.setAccountBankCity("上海");
//        bizContent.setAccountBankNm("中国工商银行");
//        bizContent.setAccountBankName("中国工商银行股份有限公司上海虹桥商务区支行");
//        bizContent.setAccountBankCode("103290003108");
//        bizContent.setAccountNo("6222030200001296205");
//        bizContent.setAccountMobile("17705281311");
//        bizContent.setCertValidityl("2099‐12‐31");
        request.setBizContent(bizContent);
        System.out.println("request:" + request.toString());
        JftApiVendorEnterpriseInfoModifyResponseV1 response;
        try {
            response = (JftApiVendorEnterpriseInfoModifyResponseV1) client.execute(request,
                    System.currentTimeMillis() + "");
            if (response.isSuccess()) {
//6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
//失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }

    }

    private static void test5(DefaultIcbcClient client) {

        JftApiVendorEnterpriseInfoQueryRequestV1 request = new JftApiVendorEnterpriseInfoQueryRequestV1();
        //
        request.setServiceUrl(HTTP_URL + "/api/jft/api/vendor/enterprise/info/query/V1");
        // 请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        JftApiVendorEnterpriseInfoQueryRequestV1.JftApiVendorEnterpriseInfoQueryRequestV1Biz bizContent = new JftApiVendorEnterpriseInfoQueryRequestV1.JftApiVendorEnterpriseInfoQueryRequestV1Biz();
        bizContent.setAppId("11000000000000012156");
        bizContent.setOutVendorId("1712137033952");
        request.setBizContent(bizContent);
        JftApiVendorEnterpriseInfoQueryResponseV1 response;
        try {

            response = (JftApiVendorEnterpriseInfoQueryResponseV1) client.execute(request, System.currentTimeMillis() + "");
            if (response.isSuccess()) {
                System.out.println("customerinfo" + response.getCustomerInfo());
                System.out.println("vendorinfo" + response.getVendorInfo());
                // 业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
                // 失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }

    }

    private static void test4(DefaultIcbcClient client) {

        JftApiVendorEnterpriseInfoRegisterRequestV1 request = new JftApiVendorEnterpriseInfoRegisterRequestV1();
        request.setServiceUrl(HTTP_URL + "/api/jft/api/vendor/enterprise/info/register/V1");
        JftApiVendorEnterpriseInfoRegisterRequestV1.JftApiVendorEnterpriseInfoRegisterRequestV1Biz bizContent = new JftApiVendorEnterpriseInfoRegisterRequestV1.JftApiVendorEnterpriseInfoRegisterRequestV1Biz();
        bizContent.setAppId("11000000000000012156");
        bizContent.setOutUpperVendorId("11000000000000012156");
        bizContent.setOutVendorId(System.currentTimeMillis() + "");
        bizContent.setOutVendorManagerId(System.currentTimeMillis() + "");
        bizContent.setVendorName("果果测试");
        bizContent.setBizType("01");
        request.setBizContent(bizContent);
        JftApiVendorEnterpriseInfoRegisterResponseV1 response;
        try {
            response = (JftApiVendorEnterpriseInfoRegisterResponseV1) client.execute(request, System.currentTimeMillis() + "");
            /*
             *{"auditStatus":"04","msg_id":"1714469839210","outVendorId":"1712137033952","return_code":0,"return_msg":"注册成功","success":true,"vendorStatus":"2"}
             * 0
             */
            System.out.println(JSONObject.toJSONString(response));
            if (response.isSuccess()) {
                // 业务成功处理
                System.out.println(response.getReturnCode());
            } else {
                //失败
                System.out.println(response.getReturnCode());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }

    }

    private static void test3(DefaultIcbcClient client) {
        JftApiVendorPicDownloadRequestV1 request = new JftApiVendorPicDownloadRequestV1();

        //4、根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl("https://apipcs3.dccnet.com.cn/api/jft/api/vendor/pic/download/V1");

        //5、请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        JftApiVendorPicDownloadRequestV1.JftApiVendorPicDownloadRequestV1Biz bizContent = new JftApiVendorPicDownloadRequestV1.JftApiVendorPicDownloadRequestV1Biz();
        // merc53adbaf33ec45f4a4bfb5e0f48bf4cd
        String imageKey = "merbd2d1422720343719724b1604ad05815";
        bizContent.setImageKey(imageKey);
        bizContent.setAppId("11000000000000012156");
        bizContent.setOutVendorId("20230919A02");
        request.setBizContent(bizContent);

        JftApiVendorPicDownloadResponseV1 response;
        try {
            response = (JftApiVendorPicDownloadResponseV1) client.execute(request, System.currentTimeMillis() + "");
            if (response.isSuccess()) {
                //6、业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
                //失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }


    private static void test2(DefaultIcbcClient client) {
//        DefaultIcbcClient client = new DefaultIcbcClient(APP_ID,"RSA2", MY_PRIVATE_KEY,"UTF‐8",
//                "json",APIGW_PUBLIC_KEY,"AES",encryptKey, "", "");
        JftApiVendorPicUploadRequestV1 request = new JftApiVendorPicUploadRequestV1();
        request.setServiceUrl("https://apipcs3.dccnet.com.cn/api/jft/api/vendor/pic/upload/V1");
        JftApiVendorPicUploadRequestV1.JftApiVendorPicUploadRequestV1Biz bizContent
                = new JftApiVendorPicUploadRequestV1.JftApiVendorPicUploadRequestV1Biz();
        // base64标准格式：     
        // 需要的格式： iVBORw0KGgoAAAANSUhEUgAAAGEAAABgC  去掉前面的标识
        String imgFileToBase64 = getImgFileToBase64("C:\\Users\\fan\\Desktop\\1712127900145.jpg");
        System.out.println("imgFileToBase64 = " + imgFileToBase64);
        bizContent.setImageFile(imgFileToBase64);
        bizContent.setAppId("11000000000000012156");
        // 20230919A03
        bizContent.setOutVendorId("20230919A02"); //子商户外部系统编号
        request.setBizContent(bizContent);
        JftApiVendorPicUploadResponseV1 response;
        try {
            response = (JftApiVendorPicUploadResponseV1) client.execute(request,
                    System.currentTimeMillis() + "");
            System.out.println(JSONObject.toJSONString(response));
            if (response.isSuccess()) {
//成功
                System.out.println(response.getReturnCode());
            } else {
//失败
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }


    public static void test1(DefaultIcbcClient client) {
        // 组装调用《聚富通委托代扣签约同步开户结果查询数据接口V1》上送报文
        JftApiUserEntrustopenacctQueryRequestV1 request = new JftApiUserEntrustopenacctQueryRequestV1();
        request.setServiceUrl("https://apipcs3.dccnet.com.cn/api/jft/api/user/entrustopenacct/query/V1");

        JftApiUserEntrustopenacctQueryRequestV1.JftApiUserEntrustopenacctQueryRequestV1Biz bizContent = new JftApiUserEntrustopenacctQueryRequestV1.JftApiUserEntrustopenacctQueryRequestV1Biz();
        bizContent.setAppId(APP_ID);
        bizContent.setOutVendorId("SH000001");
        bizContent.setOutUserId("M201801112326");
        bizContent.setProjectId("PJ140014021000004309");
        bizContent.setBusiCode("888810222");
        request.setBizContent(bizContent);
        JftApiUserEntrustopenacctQueryResponseV1 response;
        try {
            response = client.execute(request, System.currentTimeMillis() + "");//msgId消息通讯唯一编号，要求每次调用独立生成，APP级唯一
            if (response.isSuccess()) {
                //业务成功处理，请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + response);
            } else {
                //失败
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
    }


    /**
     * 将本地图片转换成Base64编码字符串
     *
     * @param imgFile 图片目录路径
     * @return
     */
    public static String getImgFileToBase64(String imgFile) {
        //将图片文件转化为字节数组字符串，并对其进行Base64编码处理
        InputStream inputStream = null;
        byte[] buffer = null;
        //读取图片字节数组
        try {
            inputStream = new FileInputStream(new File(imgFile));
            int count = 0;
            while (count == 0) {
                count = inputStream.available();
            }
            buffer = new byte[count];
            inputStream.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    // 关闭inputStream流
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        // 对字节数组Base64编码
        System.out.println(Base64.encodeBase64String(buffer));
        System.out.println(java.util.Base64.getEncoder().encodeToString(buffer));
        return Base64.encodeBase64String(buffer);
    }
}